package com.soft.javase.day08.listremoverepeat;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/4/27
 */
public class ObjectRemoveRepeat {
    public static void main(String[] args) {
        List<Person> List = new ArrayList<>();
        List.add(new Person("张三", "111"));
        List.add(new Person("李四", "222"));
        List.add(new Person("张三", "111"));
        List.add(new Person("李四", "333"));
        List.add(new Person("王五", "111"));
        System.out.println("去重前："+ List);

        List<Person> changeList = new ArrayList<>();
        for (Person person : List) {
            if (!changeList.contains(person)) {
                changeList.add(person);
            }
        }

        System.out.println("去重后: "+changeList);
    }
}
